#!/bin/bash

USAGE="`basename $0` [-w|--warning]"

if [ $# -ne 2 ];then
    echo -e "\nWrong Syntax:`basename $0` $*"
    echo -e "\nUsage: $USAGE\n"
    exit 2
fi

case "$1" in
    -w|--warning)
        shift
        WAR=$1
        ;;
    *)
        echo -e "\nWrong Syntax:`basename $0` $*"
        echo -e "\nUsage: $USAGE\n"
        exit 2
esac

procsnum=$(ls /proc/|grep -E '[0-9]+'|wc -l)

echo "Total have $procsnum processes|procs:$procsnum:$WAR"

if [ $procsnum -lt $WAR ];then
    exit 0
else
    exit 1
fi
